package reflect;

import reflect.annotations.AutoRunClass;
import reflect.annotations.AutoRunMethod;

import java.lang.reflect.Method;

public class Test3 {
    public static void main(String[] args) throws  Exception{
        Class cls = Class.forName("reflect.Person");
        Object obj = cls.newInstance();
        Method[] methods = cls.getMethods();
        boolean mark;
        for (Method m : methods){
            mark = m.isAnnotationPresent(AutoRunMethod.class);
            if(mark){
                System.out.print(m.getName()+":");
                m.invoke(obj);
            }
        }
    }
}
